package com.zxp.oauth2.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shollin
 * @desc
 * @date 2021/8/1/001 13:52
 */
@RestController
public class IndexController {

    @GetMapping("/")
    public String index(){
        return "资料服务器1首页";
    }

    @GetMapping("/user")
    @PreAuthorize("hasAuthority('user')")
    public String user(){
        return "user";
    }

    @GetMapping("/admin")
    @PreAuthorize("hasAuthority('admin')")
    public String admin(){
        return "admin";
    }

    @GetMapping("/me")
    public Object admin(Authentication authentication){
        return authentication.getPrincipal();
    }
}
